import {PublishConfiguration} from "builder-util-runtime/out/publishOptions";

export interface GiteeOptions extends PublishConfiguration {
  /**
   * The provider. Must be `gitee`.
   */
  readonly provider: "gitee";
  /**
   * The repository name. [Detected automatically](#gitee-repository-and-bintray-package).
   */
  readonly repo?: string | null;
  /**
   * The owner.
   */
  readonly owner?: string | null;
  /**
   * Whether to use `v`-prefixed tag name.
   * @default true
   */
  readonly vPrefixedTagName?: boolean;
  /**
   * The host (including the port if need).
   * @default gitee.com
   */
  readonly host?: string | null;
  /**
   * The protocol. GitCode Publisher supports only `https`.
   * @default https
   */
  readonly protocol?: "https" | "http" | null;
  /**
   * The access token to support auto-update from private gitee repositories. Never specify it in the configuration files. Only for [setFeedURL](/auto-update#appupdatersetfeedurloptions).
   */
  readonly token?: string | null;
  /**
   * Whether to use private gitee auto-update provider if `GH_TOKEN` environment variable is defined. See [Private GitCode Update Repo](/auto-update#private-gitee-update-repo).
   */
  readonly private?: boolean | null;
  /**
   * The channel.
   * @default latest
   */
  readonly channel?: string | null;
  /**
   * The type of release. By default `draft` release will be created.
   *
   * Also you can set release type using environment variable. If `EP_DRAFT`is set to `true` — `draft`, if `EP_PRE_RELEASE`is set to `true` — `prerelease`.
   * @default draft
   */
  releaseType?: "draft" | "prerelease" | "release" | null;
}

export function giteeUrl(options, defaultHost = "gitee.com") {
  return `${options.protocol || "https"}://${options.host || defaultHost}`;
}